// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations;

[JsonConverter(typeof(AggregationConverter))]
public sealed partial class Aggregation
{
	internal Aggregation(string variantName, object variant)
	{
		if (variantName is null)
			throw new ArgumentNullException(nameof(variantName));
		if (variant is null)
			throw new ArgumentNullException(nameof(variant));
		if (string.IsNullOrWhiteSpace(variantName))
			throw new ArgumentException("Variant name must not be empty or whitespace.");
		VariantName = variantName;
		Variant = variant;
	}

	internal object Variant { get; }
	internal string VariantName { get; }

	public static Aggregation AdjacencyMatrix(Elastic.Clients.Elasticsearch.Serverless.Aggregations.AdjacencyMatrixAggregation adjacencyMatrixAggregation) => new Aggregation("adjacency_matrix", adjacencyMatrixAggregation);
	public static Aggregation AutoDateHistogram(Elastic.Clients.Elasticsearch.Serverless.Aggregations.AutoDateHistogramAggregation autoDateHistogramAggregation) => new Aggregation("auto_date_histogram", autoDateHistogramAggregation);
	public static Aggregation Avg(Elastic.Clients.Elasticsearch.Serverless.Aggregations.AverageAggregation averageAggregation) => new Aggregation("avg", averageAggregation);
	public static Aggregation AvgBucket(Elastic.Clients.Elasticsearch.Serverless.Aggregations.AverageBucketAggregation averageBucketAggregation) => new Aggregation("avg_bucket", averageBucketAggregation);
	public static Aggregation Boxplot(Elastic.Clients.Elasticsearch.Serverless.Aggregations.BoxplotAggregation boxplotAggregation) => new Aggregation("boxplot", boxplotAggregation);
	public static Aggregation BucketScript(Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketScriptAggregation bucketScriptAggregation) => new Aggregation("bucket_script", bucketScriptAggregation);
	public static Aggregation BucketSelector(Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketSelectorAggregation bucketSelectorAggregation) => new Aggregation("bucket_selector", bucketSelectorAggregation);
	public static Aggregation BucketSort(Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketSortAggregation bucketSortAggregation) => new Aggregation("bucket_sort", bucketSortAggregation);
	public static Aggregation Cardinality(Elastic.Clients.Elasticsearch.Serverless.Aggregations.CardinalityAggregation cardinalityAggregation) => new Aggregation("cardinality", cardinalityAggregation);
	public static Aggregation Children(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ChildrenAggregation childrenAggregation) => new Aggregation("children", childrenAggregation);
	public static Aggregation Composite(Elastic.Clients.Elasticsearch.Serverless.Aggregations.CompositeAggregation compositeAggregation) => new Aggregation("composite", compositeAggregation);
	public static Aggregation CumulativeCardinality(Elastic.Clients.Elasticsearch.Serverless.Aggregations.CumulativeCardinalityAggregation cumulativeCardinalityAggregation) => new Aggregation("cumulative_cardinality", cumulativeCardinalityAggregation);
	public static Aggregation CumulativeSum(Elastic.Clients.Elasticsearch.Serverless.Aggregations.CumulativeSumAggregation cumulativeSumAggregation) => new Aggregation("cumulative_sum", cumulativeSumAggregation);
	public static Aggregation DateHistogram(Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateHistogramAggregation dateHistogramAggregation) => new Aggregation("date_histogram", dateHistogramAggregation);
	public static Aggregation DateRange(Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateRangeAggregation dateRangeAggregation) => new Aggregation("date_range", dateRangeAggregation);
	public static Aggregation Derivative(Elastic.Clients.Elasticsearch.Serverless.Aggregations.DerivativeAggregation derivativeAggregation) => new Aggregation("derivative", derivativeAggregation);
	public static Aggregation DiversifiedSampler(Elastic.Clients.Elasticsearch.Serverless.Aggregations.DiversifiedSamplerAggregation diversifiedSamplerAggregation) => new Aggregation("diversified_sampler", diversifiedSamplerAggregation);
	public static Aggregation ExtendedStats(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsAggregation extendedStatsAggregation) => new Aggregation("extended_stats", extendedStatsAggregation);
	public static Aggregation ExtendedStatsBucket(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsBucketAggregation extendedStatsBucketAggregation) => new Aggregation("extended_stats_bucket", extendedStatsBucketAggregation);
	public static Aggregation Filter(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query queryContainer) => new Aggregation("filter", queryContainer);
	public static Aggregation Filters(Elastic.Clients.Elasticsearch.Serverless.Aggregations.FiltersAggregation filtersAggregation) => new Aggregation("filters", filtersAggregation);
	public static Aggregation FrequentItemSets(Elastic.Clients.Elasticsearch.Serverless.Aggregations.FrequentItemSetsAggregation frequentItemSetsAggregation) => new Aggregation("frequent_item_sets", frequentItemSetsAggregation);
	public static Aggregation GeoBounds(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoBoundsAggregation geoBoundsAggregation) => new Aggregation("geo_bounds", geoBoundsAggregation);
	public static Aggregation GeoCentroid(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoCentroidAggregation geoCentroidAggregation) => new Aggregation("geo_centroid", geoCentroidAggregation);
	public static Aggregation GeoDistance(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoDistanceAggregation geoDistanceAggregation) => new Aggregation("geo_distance", geoDistanceAggregation);
	public static Aggregation GeohashGrid(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohashGridAggregation geohashGridAggregation) => new Aggregation("geohash_grid", geohashGridAggregation);
	public static Aggregation GeohexGrid(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohexGridAggregation geohexGridAggregation) => new Aggregation("geohex_grid", geohexGridAggregation);
	public static Aggregation GeoLine(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoLineAggregation geoLineAggregation) => new Aggregation("geo_line", geoLineAggregation);
	public static Aggregation GeotileGrid(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeotileGridAggregation geotileGridAggregation) => new Aggregation("geotile_grid", geotileGridAggregation);
	public static Aggregation Global(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GlobalAggregation globalAggregation) => new Aggregation("global", globalAggregation);
	public static Aggregation Histogram(Elastic.Clients.Elasticsearch.Serverless.Aggregations.HistogramAggregation histogramAggregation) => new Aggregation("histogram", histogramAggregation);
	public static Aggregation Inference(Elastic.Clients.Elasticsearch.Serverless.Aggregations.InferenceAggregation inferenceAggregation) => new Aggregation("inference", inferenceAggregation);
	public static Aggregation IpPrefix(Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpPrefixAggregation ipPrefixAggregation) => new Aggregation("ip_prefix", ipPrefixAggregation);
	public static Aggregation IpRange(Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpRangeAggregation ipRangeAggregation) => new Aggregation("ip_range", ipRangeAggregation);
	public static Aggregation Line(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoLineAggregation geoLineAggregation) => new Aggregation("line", geoLineAggregation);
	public static Aggregation MatrixStats(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MatrixStatsAggregation matrixStatsAggregation) => new Aggregation("matrix_stats", matrixStatsAggregation);
	public static Aggregation Max(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MaxAggregation maxAggregation) => new Aggregation("max", maxAggregation);
	public static Aggregation MaxBucket(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MaxBucketAggregation maxBucketAggregation) => new Aggregation("max_bucket", maxBucketAggregation);
	public static Aggregation MedianAbsoluteDeviation(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MedianAbsoluteDeviationAggregation medianAbsoluteDeviationAggregation) => new Aggregation("median_absolute_deviation", medianAbsoluteDeviationAggregation);
	public static Aggregation Min(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MinAggregation minAggregation) => new Aggregation("min", minAggregation);
	public static Aggregation MinBucket(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MinBucketAggregation minBucketAggregation) => new Aggregation("min_bucket", minBucketAggregation);
	public static Aggregation Missing(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MissingAggregation missingAggregation) => new Aggregation("missing", missingAggregation);
	public static Aggregation MovingFn(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MovingFunctionAggregation movingFunctionAggregation) => new Aggregation("moving_fn", movingFunctionAggregation);
	public static Aggregation MovingPercentiles(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MovingPercentilesAggregation movingPercentilesAggregation) => new Aggregation("moving_percentiles", movingPercentilesAggregation);
	public static Aggregation MultiTerms(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MultiTermsAggregation multiTermsAggregation) => new Aggregation("multi_terms", multiTermsAggregation);
	public static Aggregation Nested(Elastic.Clients.Elasticsearch.Serverless.Aggregations.NestedAggregation nestedAggregation) => new Aggregation("nested", nestedAggregation);
	public static Aggregation Normalize(Elastic.Clients.Elasticsearch.Serverless.Aggregations.NormalizeAggregation normalizeAggregation) => new Aggregation("normalize", normalizeAggregation);
	public static Aggregation Parent(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ParentAggregation parentAggregation) => new Aggregation("parent", parentAggregation);
	public static Aggregation PercentileRanks(Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentileRanksAggregation percentileRanksAggregation) => new Aggregation("percentile_ranks", percentileRanksAggregation);
	public static Aggregation Percentiles(Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentilesAggregation percentilesAggregation) => new Aggregation("percentiles", percentilesAggregation);
	public static Aggregation PercentilesBucket(Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentilesBucketAggregation percentilesBucketAggregation) => new Aggregation("percentiles_bucket", percentilesBucketAggregation);
	public static Aggregation Range(Elastic.Clients.Elasticsearch.Serverless.Aggregations.RangeAggregation rangeAggregation) => new Aggregation("range", rangeAggregation);
	public static Aggregation RareTerms(Elastic.Clients.Elasticsearch.Serverless.Aggregations.RareTermsAggregation rareTermsAggregation) => new Aggregation("rare_terms", rareTermsAggregation);
	public static Aggregation Rate(Elastic.Clients.Elasticsearch.Serverless.Aggregations.RateAggregation rateAggregation) => new Aggregation("rate", rateAggregation);
	public static Aggregation ReverseNested(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ReverseNestedAggregation reverseNestedAggregation) => new Aggregation("reverse_nested", reverseNestedAggregation);
	public static Aggregation Sampler(Elastic.Clients.Elasticsearch.Serverless.Aggregations.SamplerAggregation samplerAggregation) => new Aggregation("sampler", samplerAggregation);
	public static Aggregation ScriptedMetric(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ScriptedMetricAggregation scriptedMetricAggregation) => new Aggregation("scripted_metric", scriptedMetricAggregation);
	public static Aggregation SerialDiff(Elastic.Clients.Elasticsearch.Serverless.Aggregations.SerialDifferencingAggregation serialDifferencingAggregation) => new Aggregation("serial_diff", serialDifferencingAggregation);
	public static Aggregation SignificantTerms(Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantTermsAggregation significantTermsAggregation) => new Aggregation("significant_terms", significantTermsAggregation);
	public static Aggregation SignificantText(Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantTextAggregation significantTextAggregation) => new Aggregation("significant_text", significantTextAggregation);
	public static Aggregation Stats(Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsAggregation statsAggregation) => new Aggregation("stats", statsAggregation);
	public static Aggregation StatsBucket(Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsBucketAggregation statsBucketAggregation) => new Aggregation("stats_bucket", statsBucketAggregation);
	public static Aggregation StringStats(Elastic.Clients.Elasticsearch.Serverless.Aggregations.StringStatsAggregation stringStatsAggregation) => new Aggregation("string_stats", stringStatsAggregation);
	public static Aggregation Sum(Elastic.Clients.Elasticsearch.Serverless.Aggregations.SumAggregation sumAggregation) => new Aggregation("sum", sumAggregation);
	public static Aggregation SumBucket(Elastic.Clients.Elasticsearch.Serverless.Aggregations.SumBucketAggregation sumBucketAggregation) => new Aggregation("sum_bucket", sumBucketAggregation);
	public static Aggregation Terms(Elastic.Clients.Elasticsearch.Serverless.Aggregations.TermsAggregation termsAggregation) => new Aggregation("terms", termsAggregation);
	public static Aggregation TopHits(Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopHitsAggregation topHitsAggregation) => new Aggregation("top_hits", topHitsAggregation);
	public static Aggregation TopMetrics(Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopMetricsAggregation topMetricsAggregation) => new Aggregation("top_metrics", topMetricsAggregation);
	public static Aggregation TTest(Elastic.Clients.Elasticsearch.Serverless.Aggregations.TTestAggregation tTestAggregation) => new Aggregation("t_test", tTestAggregation);
	public static Aggregation ValueCount(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ValueCountAggregation valueCountAggregation) => new Aggregation("value_count", valueCountAggregation);
	public static Aggregation VariableWidthHistogram(Elastic.Clients.Elasticsearch.Serverless.Aggregations.VariableWidthHistogramAggregation variableWidthHistogramAggregation) => new Aggregation("variable_width_histogram", variableWidthHistogramAggregation);
	public static Aggregation WeightedAvg(Elastic.Clients.Elasticsearch.Serverless.Aggregations.WeightedAverageAggregation weightedAverageAggregation) => new Aggregation("weighted_avg", weightedAverageAggregation);

	/// <summary>
	/// <para>Sub-aggregations for this aggregation.<br/>Only applies to bucket aggregations.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("aggregations")]
	public IDictionary<string, Elastic.Clients.Elasticsearch.Serverless.Aggregations.Aggregation>? Aggregations { get; set; }
	[JsonInclude, JsonPropertyName("meta")]
	public IDictionary<string, object>? Meta { get; set; }

	public bool TryGet<T>([NotNullWhen(true)] out T? result) where T : class
	{
		result = default;
		if (Variant is T variant)
		{
			result = variant;
			return true;
		}

		return false;
	}
}

internal sealed partial class AggregationConverter : JsonConverter<Aggregation>
{
	public override Aggregation Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
	{
		if (reader.TokenType != JsonTokenType.StartObject)
		{
			throw new JsonException("Expected start token.");
		}

		object? variantValue = default;
		string? variantNameValue = default;
		IDictionary<string, Elastic.Clients.Elasticsearch.Serverless.Aggregations.Aggregation>? aggregationsValue = default;
		IDictionary<string, object>? metaValue = default;
		while (reader.Read() && reader.TokenType != JsonTokenType.EndObject)
		{
			if (reader.TokenType != JsonTokenType.PropertyName)
			{
				throw new JsonException("Expected a property name token.");
			}

			if (reader.TokenType != JsonTokenType.PropertyName)
			{
				throw new JsonException("Expected a property name token representing the name of an Elasticsearch field.");
			}

			var propertyName = reader.GetString();
			reader.Read();
			if (propertyName == "aggregations")
			{
				aggregationsValue = JsonSerializer.Deserialize<IDictionary<string, Elastic.Clients.Elasticsearch.Serverless.Aggregations.Aggregation>?>(ref reader, options);
				continue;
			}

			if (propertyName == "meta")
			{
				metaValue = JsonSerializer.Deserialize<IDictionary<string, object>?>(ref reader, options);
				continue;
			}

			if (propertyName == "adjacency_matrix")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.AdjacencyMatrixAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "auto_date_histogram")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.AutoDateHistogramAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "avg")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.AverageAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "avg_bucket")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.AverageBucketAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "boxplot")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.BoxplotAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "bucket_script")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketScriptAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "bucket_selector")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketSelectorAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "bucket_sort")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketSortAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "cardinality")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.CardinalityAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "children")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ChildrenAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "composite")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.CompositeAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "cumulative_cardinality")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.CumulativeCardinalityAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "cumulative_sum")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.CumulativeSumAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "date_histogram")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateHistogramAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "date_range")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateRangeAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "derivative")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.DerivativeAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "diversified_sampler")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.DiversifiedSamplerAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "extended_stats")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "extended_stats_bucket")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsBucketAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "filter")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "filters")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.FiltersAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "frequent_item_sets")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.FrequentItemSetsAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "geo_bounds")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoBoundsAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "geo_centroid")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoCentroidAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "geo_distance")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoDistanceAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "geohash_grid")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohashGridAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "geohex_grid")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohexGridAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "geo_line")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoLineAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "geotile_grid")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeotileGridAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "global")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GlobalAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "histogram")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.HistogramAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "inference")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.InferenceAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "ip_prefix")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpPrefixAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "ip_range")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpRangeAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "line")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoLineAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "matrix_stats")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MatrixStatsAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "max")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MaxAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "max_bucket")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MaxBucketAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "median_absolute_deviation")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MedianAbsoluteDeviationAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "min")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MinAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "min_bucket")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MinBucketAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "missing")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MissingAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "moving_fn")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MovingFunctionAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "moving_percentiles")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MovingPercentilesAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "multi_terms")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MultiTermsAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "nested")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.NestedAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "normalize")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.NormalizeAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "parent")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ParentAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "percentile_ranks")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentileRanksAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "percentiles")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentilesAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "percentiles_bucket")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentilesBucketAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "range")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.RangeAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "rare_terms")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.RareTermsAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "rate")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.RateAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "reverse_nested")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ReverseNestedAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "sampler")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SamplerAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "scripted_metric")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ScriptedMetricAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "serial_diff")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SerialDifferencingAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "significant_terms")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantTermsAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "significant_text")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantTextAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "stats")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "stats_bucket")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsBucketAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "string_stats")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.StringStatsAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "sum")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SumAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "sum_bucket")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SumBucketAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "terms")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TermsAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "top_hits")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopHitsAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "top_metrics")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopMetricsAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "t_test")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TTestAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "value_count")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ValueCountAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "variable_width_histogram")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.VariableWidthHistogramAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "weighted_avg")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.WeightedAverageAggregation?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'Aggregation' from the response.");
		}

		var result = new Aggregation(variantNameValue, variantValue);
		result.Aggregations = aggregationsValue;
		result.Meta = metaValue;
		return result;
	}

	public override void Write(Utf8JsonWriter writer, Aggregation value, JsonSerializerOptions options)
	{
		writer.WriteStartObject();
		if (value.Aggregations is not null)
		{
			writer.WritePropertyName("aggregations");
			JsonSerializer.Serialize(writer, value.Aggregations, options);
		}

		if (value.Meta is not null)
		{
			writer.WritePropertyName("meta");
			JsonSerializer.Serialize(writer, value.Meta, options);
		}

		if (value.VariantName is not null && value.Variant is not null)
		{
			writer.WritePropertyName(value.VariantName);
			switch (value.VariantName)
			{
				case "adjacency_matrix":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.AdjacencyMatrixAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.AdjacencyMatrixAggregation)value.Variant, options);
					break;
				case "auto_date_histogram":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.AutoDateHistogramAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.AutoDateHistogramAggregation)value.Variant, options);
					break;
				case "avg":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.AverageAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.AverageAggregation)value.Variant, options);
					break;
				case "avg_bucket":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.AverageBucketAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.AverageBucketAggregation)value.Variant, options);
					break;
				case "boxplot":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.BoxplotAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.BoxplotAggregation)value.Variant, options);
					break;
				case "bucket_script":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketScriptAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketScriptAggregation)value.Variant, options);
					break;
				case "bucket_selector":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketSelectorAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketSelectorAggregation)value.Variant, options);
					break;
				case "bucket_sort":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketSortAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketSortAggregation)value.Variant, options);
					break;
				case "cardinality":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.CardinalityAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.CardinalityAggregation)value.Variant, options);
					break;
				case "children":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ChildrenAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.ChildrenAggregation)value.Variant, options);
					break;
				case "composite":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.CompositeAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.CompositeAggregation)value.Variant, options);
					break;
				case "cumulative_cardinality":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.CumulativeCardinalityAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.CumulativeCardinalityAggregation)value.Variant, options);
					break;
				case "cumulative_sum":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.CumulativeSumAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.CumulativeSumAggregation)value.Variant, options);
					break;
				case "date_histogram":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateHistogramAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateHistogramAggregation)value.Variant, options);
					break;
				case "date_range":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateRangeAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateRangeAggregation)value.Variant, options);
					break;
				case "derivative":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.DerivativeAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.DerivativeAggregation)value.Variant, options);
					break;
				case "diversified_sampler":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.DiversifiedSamplerAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.DiversifiedSamplerAggregation)value.Variant, options);
					break;
				case "extended_stats":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsAggregation)value.Variant, options);
					break;
				case "extended_stats_bucket":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsBucketAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsBucketAggregation)value.Variant, options);
					break;
				case "filter":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query>(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query)value.Variant, options);
					break;
				case "filters":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.FiltersAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.FiltersAggregation)value.Variant, options);
					break;
				case "frequent_item_sets":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.FrequentItemSetsAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.FrequentItemSetsAggregation)value.Variant, options);
					break;
				case "geo_bounds":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoBoundsAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoBoundsAggregation)value.Variant, options);
					break;
				case "geo_centroid":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoCentroidAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoCentroidAggregation)value.Variant, options);
					break;
				case "geo_distance":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoDistanceAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoDistanceAggregation)value.Variant, options);
					break;
				case "geohash_grid":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohashGridAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohashGridAggregation)value.Variant, options);
					break;
				case "geohex_grid":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohexGridAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohexGridAggregation)value.Variant, options);
					break;
				case "geo_line":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoLineAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoLineAggregation)value.Variant, options);
					break;
				case "geotile_grid":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeotileGridAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeotileGridAggregation)value.Variant, options);
					break;
				case "global":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GlobalAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GlobalAggregation)value.Variant, options);
					break;
				case "histogram":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.HistogramAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.HistogramAggregation)value.Variant, options);
					break;
				case "inference":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.InferenceAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.InferenceAggregation)value.Variant, options);
					break;
				case "ip_prefix":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpPrefixAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpPrefixAggregation)value.Variant, options);
					break;
				case "ip_range":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpRangeAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpRangeAggregation)value.Variant, options);
					break;
				case "line":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoLineAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoLineAggregation)value.Variant, options);
					break;
				case "matrix_stats":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MatrixStatsAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MatrixStatsAggregation)value.Variant, options);
					break;
				case "max":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MaxAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MaxAggregation)value.Variant, options);
					break;
				case "max_bucket":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MaxBucketAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MaxBucketAggregation)value.Variant, options);
					break;
				case "median_absolute_deviation":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MedianAbsoluteDeviationAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MedianAbsoluteDeviationAggregation)value.Variant, options);
					break;
				case "min":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MinAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MinAggregation)value.Variant, options);
					break;
				case "min_bucket":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MinBucketAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MinBucketAggregation)value.Variant, options);
					break;
				case "missing":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MissingAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MissingAggregation)value.Variant, options);
					break;
				case "moving_fn":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MovingFunctionAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MovingFunctionAggregation)value.Variant, options);
					break;
				case "moving_percentiles":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MovingPercentilesAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MovingPercentilesAggregation)value.Variant, options);
					break;
				case "multi_terms":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MultiTermsAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MultiTermsAggregation)value.Variant, options);
					break;
				case "nested":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.NestedAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.NestedAggregation)value.Variant, options);
					break;
				case "normalize":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.NormalizeAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.NormalizeAggregation)value.Variant, options);
					break;
				case "parent":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ParentAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.ParentAggregation)value.Variant, options);
					break;
				case "percentile_ranks":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentileRanksAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentileRanksAggregation)value.Variant, options);
					break;
				case "percentiles":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentilesAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentilesAggregation)value.Variant, options);
					break;
				case "percentiles_bucket":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentilesBucketAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentilesBucketAggregation)value.Variant, options);
					break;
				case "range":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.RangeAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.RangeAggregation)value.Variant, options);
					break;
				case "rare_terms":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.RareTermsAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.RareTermsAggregation)value.Variant, options);
					break;
				case "rate":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.RateAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.RateAggregation)value.Variant, options);
					break;
				case "reverse_nested":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ReverseNestedAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.ReverseNestedAggregation)value.Variant, options);
					break;
				case "sampler":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SamplerAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.SamplerAggregation)value.Variant, options);
					break;
				case "scripted_metric":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ScriptedMetricAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.ScriptedMetricAggregation)value.Variant, options);
					break;
				case "serial_diff":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SerialDifferencingAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.SerialDifferencingAggregation)value.Variant, options);
					break;
				case "significant_terms":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantTermsAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantTermsAggregation)value.Variant, options);
					break;
				case "significant_text":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantTextAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantTextAggregation)value.Variant, options);
					break;
				case "stats":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsAggregation)value.Variant, options);
					break;
				case "stats_bucket":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsBucketAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsBucketAggregation)value.Variant, options);
					break;
				case "string_stats":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.StringStatsAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.StringStatsAggregation)value.Variant, options);
					break;
				case "sum":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SumAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.SumAggregation)value.Variant, options);
					break;
				case "sum_bucket":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SumBucketAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.SumBucketAggregation)value.Variant, options);
					break;
				case "terms":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TermsAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.TermsAggregation)value.Variant, options);
					break;
				case "top_hits":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopHitsAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopHitsAggregation)value.Variant, options);
					break;
				case "top_metrics":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopMetricsAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopMetricsAggregation)value.Variant, options);
					break;
				case "t_test":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TTestAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.TTestAggregation)value.Variant, options);
					break;
				case "value_count":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ValueCountAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.ValueCountAggregation)value.Variant, options);
					break;
				case "variable_width_histogram":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.VariableWidthHistogramAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.VariableWidthHistogramAggregation)value.Variant, options);
					break;
				case "weighted_avg":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Aggregations.WeightedAverageAggregation>(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.WeightedAverageAggregation)value.Variant, options);
					break;
			}
		}

		writer.WriteEndObject();
	}
}

public sealed partial class AggregationDescriptor<TDocument> : SerializableDescriptor<AggregationDescriptor<TDocument>>
{
	internal AggregationDescriptor(Action<AggregationDescriptor<TDocument>> configure) => configure.Invoke(this);

	public AggregationDescriptor() : base()
	{
	}

	private bool ContainsVariant { get; set; }
	private string ContainedVariantName { get; set; }
	private object Variant { get; set; }
	private Descriptor Descriptor { get; set; }

	private AggregationDescriptor<TDocument> Set<T>(Action<T> descriptorAction, string variantName) where T : Descriptor
	{
		ContainedVariantName = variantName;
		ContainsVariant = true;
		var descriptor = (T)Activator.CreateInstance(typeof(T), true);
		descriptorAction?.Invoke(descriptor);
		Descriptor = descriptor;
		return Self;
	}

	private AggregationDescriptor<TDocument> Set(object variant, string variantName)
	{
		Variant = variant;
		ContainedVariantName = variantName;
		ContainsVariant = true;
		return Self;
	}

	private IDictionary<string, Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregationDescriptor<TDocument>> AggregationsValue { get; set; }
	private IDictionary<string, object>? MetaValue { get; set; }

	/// <summary>
	/// <para>Sub-aggregations for this aggregation.<br/>Only applies to bucket aggregations.</para>
	/// </summary>
	public AggregationDescriptor<TDocument> Aggregations(Func<FluentDescriptorDictionary<string, Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregationDescriptor<TDocument>>, FluentDescriptorDictionary<string, Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregationDescriptor<TDocument>>> selector)
	{
		AggregationsValue = selector?.Invoke(new FluentDescriptorDictionary<string, Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregationDescriptor<TDocument>>());
		return Self;
	}

	public AggregationDescriptor<TDocument> Meta(Func<FluentDictionary<string, object>, FluentDictionary<string, object>> selector)
	{
		MetaValue = selector?.Invoke(new FluentDictionary<string, object>());
		return Self;
	}

	public AggregationDescriptor<TDocument> AdjacencyMatrix(Elastic.Clients.Elasticsearch.Serverless.Aggregations.AdjacencyMatrixAggregation adjacencyMatrixAggregation) => Set(adjacencyMatrixAggregation, "adjacency_matrix");
	public AggregationDescriptor<TDocument> AdjacencyMatrix(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.AdjacencyMatrixAggregationDescriptor<TDocument>> configure) => Set(configure, "adjacency_matrix");
	public AggregationDescriptor<TDocument> AutoDateHistogram(Elastic.Clients.Elasticsearch.Serverless.Aggregations.AutoDateHistogramAggregation autoDateHistogramAggregation) => Set(autoDateHistogramAggregation, "auto_date_histogram");
	public AggregationDescriptor<TDocument> AutoDateHistogram(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.AutoDateHistogramAggregationDescriptor<TDocument>> configure) => Set(configure, "auto_date_histogram");
	public AggregationDescriptor<TDocument> Avg(Elastic.Clients.Elasticsearch.Serverless.Aggregations.AverageAggregation averageAggregation) => Set(averageAggregation, "avg");
	public AggregationDescriptor<TDocument> Avg(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.AverageAggregationDescriptor<TDocument>> configure) => Set(configure, "avg");
	public AggregationDescriptor<TDocument> AvgBucket(Elastic.Clients.Elasticsearch.Serverless.Aggregations.AverageBucketAggregation averageBucketAggregation) => Set(averageBucketAggregation, "avg_bucket");
	public AggregationDescriptor<TDocument> AvgBucket(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.AverageBucketAggregationDescriptor> configure) => Set(configure, "avg_bucket");
	public AggregationDescriptor<TDocument> Boxplot(Elastic.Clients.Elasticsearch.Serverless.Aggregations.BoxplotAggregation boxplotAggregation) => Set(boxplotAggregation, "boxplot");
	public AggregationDescriptor<TDocument> Boxplot(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.BoxplotAggregationDescriptor<TDocument>> configure) => Set(configure, "boxplot");
	public AggregationDescriptor<TDocument> BucketScript(Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketScriptAggregation bucketScriptAggregation) => Set(bucketScriptAggregation, "bucket_script");
	public AggregationDescriptor<TDocument> BucketScript(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketScriptAggregationDescriptor> configure) => Set(configure, "bucket_script");
	public AggregationDescriptor<TDocument> BucketSelector(Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketSelectorAggregation bucketSelectorAggregation) => Set(bucketSelectorAggregation, "bucket_selector");
	public AggregationDescriptor<TDocument> BucketSelector(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketSelectorAggregationDescriptor> configure) => Set(configure, "bucket_selector");
	public AggregationDescriptor<TDocument> BucketSort(Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketSortAggregation bucketSortAggregation) => Set(bucketSortAggregation, "bucket_sort");
	public AggregationDescriptor<TDocument> BucketSort(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketSortAggregationDescriptor<TDocument>> configure) => Set(configure, "bucket_sort");
	public AggregationDescriptor<TDocument> Cardinality(Elastic.Clients.Elasticsearch.Serverless.Aggregations.CardinalityAggregation cardinalityAggregation) => Set(cardinalityAggregation, "cardinality");
	public AggregationDescriptor<TDocument> Cardinality(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.CardinalityAggregationDescriptor<TDocument>> configure) => Set(configure, "cardinality");
	public AggregationDescriptor<TDocument> Children(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ChildrenAggregation childrenAggregation) => Set(childrenAggregation, "children");
	public AggregationDescriptor<TDocument> Children(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ChildrenAggregationDescriptor> configure) => Set(configure, "children");
	public AggregationDescriptor<TDocument> Composite(Elastic.Clients.Elasticsearch.Serverless.Aggregations.CompositeAggregation compositeAggregation) => Set(compositeAggregation, "composite");
	public AggregationDescriptor<TDocument> Composite(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.CompositeAggregationDescriptor<TDocument>> configure) => Set(configure, "composite");
	public AggregationDescriptor<TDocument> CumulativeCardinality(Elastic.Clients.Elasticsearch.Serverless.Aggregations.CumulativeCardinalityAggregation cumulativeCardinalityAggregation) => Set(cumulativeCardinalityAggregation, "cumulative_cardinality");
	public AggregationDescriptor<TDocument> CumulativeCardinality(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.CumulativeCardinalityAggregationDescriptor> configure) => Set(configure, "cumulative_cardinality");
	public AggregationDescriptor<TDocument> CumulativeSum(Elastic.Clients.Elasticsearch.Serverless.Aggregations.CumulativeSumAggregation cumulativeSumAggregation) => Set(cumulativeSumAggregation, "cumulative_sum");
	public AggregationDescriptor<TDocument> CumulativeSum(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.CumulativeSumAggregationDescriptor> configure) => Set(configure, "cumulative_sum");
	public AggregationDescriptor<TDocument> DateHistogram(Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateHistogramAggregation dateHistogramAggregation) => Set(dateHistogramAggregation, "date_histogram");
	public AggregationDescriptor<TDocument> DateHistogram(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateHistogramAggregationDescriptor<TDocument>> configure) => Set(configure, "date_histogram");
	public AggregationDescriptor<TDocument> DateRange(Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateRangeAggregation dateRangeAggregation) => Set(dateRangeAggregation, "date_range");
	public AggregationDescriptor<TDocument> DateRange(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateRangeAggregationDescriptor<TDocument>> configure) => Set(configure, "date_range");
	public AggregationDescriptor<TDocument> Derivative(Elastic.Clients.Elasticsearch.Serverless.Aggregations.DerivativeAggregation derivativeAggregation) => Set(derivativeAggregation, "derivative");
	public AggregationDescriptor<TDocument> Derivative(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.DerivativeAggregationDescriptor> configure) => Set(configure, "derivative");
	public AggregationDescriptor<TDocument> DiversifiedSampler(Elastic.Clients.Elasticsearch.Serverless.Aggregations.DiversifiedSamplerAggregation diversifiedSamplerAggregation) => Set(diversifiedSamplerAggregation, "diversified_sampler");
	public AggregationDescriptor<TDocument> DiversifiedSampler(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.DiversifiedSamplerAggregationDescriptor<TDocument>> configure) => Set(configure, "diversified_sampler");
	public AggregationDescriptor<TDocument> ExtendedStats(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsAggregation extendedStatsAggregation) => Set(extendedStatsAggregation, "extended_stats");
	public AggregationDescriptor<TDocument> ExtendedStats(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsAggregationDescriptor<TDocument>> configure) => Set(configure, "extended_stats");
	public AggregationDescriptor<TDocument> ExtendedStatsBucket(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsBucketAggregation extendedStatsBucketAggregation) => Set(extendedStatsBucketAggregation, "extended_stats_bucket");
	public AggregationDescriptor<TDocument> ExtendedStatsBucket(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsBucketAggregationDescriptor> configure) => Set(configure, "extended_stats_bucket");
	public AggregationDescriptor<TDocument> Filter(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query queryContainer) => Set(queryContainer, "filter");
	public AggregationDescriptor<TDocument> Filter(Action<Elastic.Clients.Elasticsearch.Serverless.QueryDsl.QueryDescriptor<TDocument>> configure) => Set(configure, "filter");
	public AggregationDescriptor<TDocument> Filters(Elastic.Clients.Elasticsearch.Serverless.Aggregations.FiltersAggregation filtersAggregation) => Set(filtersAggregation, "filters");
	public AggregationDescriptor<TDocument> Filters(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.FiltersAggregationDescriptor<TDocument>> configure) => Set(configure, "filters");
	public AggregationDescriptor<TDocument> FrequentItemSets(Elastic.Clients.Elasticsearch.Serverless.Aggregations.FrequentItemSetsAggregation frequentItemSetsAggregation) => Set(frequentItemSetsAggregation, "frequent_item_sets");
	public AggregationDescriptor<TDocument> FrequentItemSets(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.FrequentItemSetsAggregationDescriptor<TDocument>> configure) => Set(configure, "frequent_item_sets");
	public AggregationDescriptor<TDocument> GeoBounds(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoBoundsAggregation geoBoundsAggregation) => Set(geoBoundsAggregation, "geo_bounds");
	public AggregationDescriptor<TDocument> GeoBounds(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoBoundsAggregationDescriptor<TDocument>> configure) => Set(configure, "geo_bounds");
	public AggregationDescriptor<TDocument> GeoCentroid(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoCentroidAggregation geoCentroidAggregation) => Set(geoCentroidAggregation, "geo_centroid");
	public AggregationDescriptor<TDocument> GeoCentroid(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoCentroidAggregationDescriptor<TDocument>> configure) => Set(configure, "geo_centroid");
	public AggregationDescriptor<TDocument> GeoDistance(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoDistanceAggregation geoDistanceAggregation) => Set(geoDistanceAggregation, "geo_distance");
	public AggregationDescriptor<TDocument> GeoDistance(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoDistanceAggregationDescriptor<TDocument>> configure) => Set(configure, "geo_distance");
	public AggregationDescriptor<TDocument> GeohashGrid(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohashGridAggregation geohashGridAggregation) => Set(geohashGridAggregation, "geohash_grid");
	public AggregationDescriptor<TDocument> GeohashGrid(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohashGridAggregationDescriptor<TDocument>> configure) => Set(configure, "geohash_grid");
	public AggregationDescriptor<TDocument> GeohexGrid(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohexGridAggregation geohexGridAggregation) => Set(geohexGridAggregation, "geohex_grid");
	public AggregationDescriptor<TDocument> GeohexGrid(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohexGridAggregationDescriptor<TDocument>> configure) => Set(configure, "geohex_grid");
	public AggregationDescriptor<TDocument> GeoLine(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoLineAggregation geoLineAggregation) => Set(geoLineAggregation, "geo_line");
	public AggregationDescriptor<TDocument> GeoLine(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoLineAggregationDescriptor<TDocument>> configure) => Set(configure, "geo_line");
	public AggregationDescriptor<TDocument> GeotileGrid(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeotileGridAggregation geotileGridAggregation) => Set(geotileGridAggregation, "geotile_grid");
	public AggregationDescriptor<TDocument> GeotileGrid(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeotileGridAggregationDescriptor<TDocument>> configure) => Set(configure, "geotile_grid");
	public AggregationDescriptor<TDocument> Global(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GlobalAggregation globalAggregation) => Set(globalAggregation, "global");
	public AggregationDescriptor<TDocument> Global(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GlobalAggregationDescriptor> configure) => Set(configure, "global");
	public AggregationDescriptor<TDocument> Histogram(Elastic.Clients.Elasticsearch.Serverless.Aggregations.HistogramAggregation histogramAggregation) => Set(histogramAggregation, "histogram");
	public AggregationDescriptor<TDocument> Histogram(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.HistogramAggregationDescriptor<TDocument>> configure) => Set(configure, "histogram");
	public AggregationDescriptor<TDocument> Inference(Elastic.Clients.Elasticsearch.Serverless.Aggregations.InferenceAggregation inferenceAggregation) => Set(inferenceAggregation, "inference");
	public AggregationDescriptor<TDocument> Inference(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.InferenceAggregationDescriptor<TDocument>> configure) => Set(configure, "inference");
	public AggregationDescriptor<TDocument> IpPrefix(Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpPrefixAggregation ipPrefixAggregation) => Set(ipPrefixAggregation, "ip_prefix");
	public AggregationDescriptor<TDocument> IpPrefix(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpPrefixAggregationDescriptor<TDocument>> configure) => Set(configure, "ip_prefix");
	public AggregationDescriptor<TDocument> IpRange(Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpRangeAggregation ipRangeAggregation) => Set(ipRangeAggregation, "ip_range");
	public AggregationDescriptor<TDocument> IpRange(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpRangeAggregationDescriptor<TDocument>> configure) => Set(configure, "ip_range");
	public AggregationDescriptor<TDocument> Line(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoLineAggregation geoLineAggregation) => Set(geoLineAggregation, "line");
	public AggregationDescriptor<TDocument> Line(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoLineAggregationDescriptor<TDocument>> configure) => Set(configure, "line");
	public AggregationDescriptor<TDocument> MatrixStats(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MatrixStatsAggregation matrixStatsAggregation) => Set(matrixStatsAggregation, "matrix_stats");
	public AggregationDescriptor<TDocument> MatrixStats(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MatrixStatsAggregationDescriptor<TDocument>> configure) => Set(configure, "matrix_stats");
	public AggregationDescriptor<TDocument> Max(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MaxAggregation maxAggregation) => Set(maxAggregation, "max");
	public AggregationDescriptor<TDocument> Max(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MaxAggregationDescriptor<TDocument>> configure) => Set(configure, "max");
	public AggregationDescriptor<TDocument> MaxBucket(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MaxBucketAggregation maxBucketAggregation) => Set(maxBucketAggregation, "max_bucket");
	public AggregationDescriptor<TDocument> MaxBucket(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MaxBucketAggregationDescriptor> configure) => Set(configure, "max_bucket");
	public AggregationDescriptor<TDocument> MedianAbsoluteDeviation(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MedianAbsoluteDeviationAggregation medianAbsoluteDeviationAggregation) => Set(medianAbsoluteDeviationAggregation, "median_absolute_deviation");
	public AggregationDescriptor<TDocument> MedianAbsoluteDeviation(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MedianAbsoluteDeviationAggregationDescriptor<TDocument>> configure) => Set(configure, "median_absolute_deviation");
	public AggregationDescriptor<TDocument> Min(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MinAggregation minAggregation) => Set(minAggregation, "min");
	public AggregationDescriptor<TDocument> Min(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MinAggregationDescriptor<TDocument>> configure) => Set(configure, "min");
	public AggregationDescriptor<TDocument> MinBucket(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MinBucketAggregation minBucketAggregation) => Set(minBucketAggregation, "min_bucket");
	public AggregationDescriptor<TDocument> MinBucket(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MinBucketAggregationDescriptor> configure) => Set(configure, "min_bucket");
	public AggregationDescriptor<TDocument> Missing(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MissingAggregation missingAggregation) => Set(missingAggregation, "missing");
	public AggregationDescriptor<TDocument> Missing(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MissingAggregationDescriptor<TDocument>> configure) => Set(configure, "missing");
	public AggregationDescriptor<TDocument> MovingFn(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MovingFunctionAggregation movingFunctionAggregation) => Set(movingFunctionAggregation, "moving_fn");
	public AggregationDescriptor<TDocument> MovingFn(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MovingFunctionAggregationDescriptor> configure) => Set(configure, "moving_fn");
	public AggregationDescriptor<TDocument> MovingPercentiles(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MovingPercentilesAggregation movingPercentilesAggregation) => Set(movingPercentilesAggregation, "moving_percentiles");
	public AggregationDescriptor<TDocument> MovingPercentiles(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MovingPercentilesAggregationDescriptor> configure) => Set(configure, "moving_percentiles");
	public AggregationDescriptor<TDocument> MultiTerms(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MultiTermsAggregation multiTermsAggregation) => Set(multiTermsAggregation, "multi_terms");
	public AggregationDescriptor<TDocument> MultiTerms(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MultiTermsAggregationDescriptor<TDocument>> configure) => Set(configure, "multi_terms");
	public AggregationDescriptor<TDocument> Nested(Elastic.Clients.Elasticsearch.Serverless.Aggregations.NestedAggregation nestedAggregation) => Set(nestedAggregation, "nested");
	public AggregationDescriptor<TDocument> Nested(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.NestedAggregationDescriptor<TDocument>> configure) => Set(configure, "nested");
	public AggregationDescriptor<TDocument> Normalize(Elastic.Clients.Elasticsearch.Serverless.Aggregations.NormalizeAggregation normalizeAggregation) => Set(normalizeAggregation, "normalize");
	public AggregationDescriptor<TDocument> Normalize(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.NormalizeAggregationDescriptor> configure) => Set(configure, "normalize");
	public AggregationDescriptor<TDocument> Parent(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ParentAggregation parentAggregation) => Set(parentAggregation, "parent");
	public AggregationDescriptor<TDocument> Parent(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ParentAggregationDescriptor> configure) => Set(configure, "parent");
	public AggregationDescriptor<TDocument> PercentileRanks(Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentileRanksAggregation percentileRanksAggregation) => Set(percentileRanksAggregation, "percentile_ranks");
	public AggregationDescriptor<TDocument> PercentileRanks(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentileRanksAggregationDescriptor<TDocument>> configure) => Set(configure, "percentile_ranks");
	public AggregationDescriptor<TDocument> Percentiles(Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentilesAggregation percentilesAggregation) => Set(percentilesAggregation, "percentiles");
	public AggregationDescriptor<TDocument> Percentiles(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentilesAggregationDescriptor<TDocument>> configure) => Set(configure, "percentiles");
	public AggregationDescriptor<TDocument> PercentilesBucket(Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentilesBucketAggregation percentilesBucketAggregation) => Set(percentilesBucketAggregation, "percentiles_bucket");
	public AggregationDescriptor<TDocument> PercentilesBucket(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentilesBucketAggregationDescriptor> configure) => Set(configure, "percentiles_bucket");
	public AggregationDescriptor<TDocument> Range(Elastic.Clients.Elasticsearch.Serverless.Aggregations.RangeAggregation rangeAggregation) => Set(rangeAggregation, "range");
	public AggregationDescriptor<TDocument> Range(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.RangeAggregationDescriptor<TDocument>> configure) => Set(configure, "range");
	public AggregationDescriptor<TDocument> RareTerms(Elastic.Clients.Elasticsearch.Serverless.Aggregations.RareTermsAggregation rareTermsAggregation) => Set(rareTermsAggregation, "rare_terms");
	public AggregationDescriptor<TDocument> RareTerms(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.RareTermsAggregationDescriptor<TDocument>> configure) => Set(configure, "rare_terms");
	public AggregationDescriptor<TDocument> Rate(Elastic.Clients.Elasticsearch.Serverless.Aggregations.RateAggregation rateAggregation) => Set(rateAggregation, "rate");
	public AggregationDescriptor<TDocument> Rate(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.RateAggregationDescriptor<TDocument>> configure) => Set(configure, "rate");
	public AggregationDescriptor<TDocument> ReverseNested(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ReverseNestedAggregation reverseNestedAggregation) => Set(reverseNestedAggregation, "reverse_nested");
	public AggregationDescriptor<TDocument> ReverseNested(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ReverseNestedAggregationDescriptor<TDocument>> configure) => Set(configure, "reverse_nested");
	public AggregationDescriptor<TDocument> Sampler(Elastic.Clients.Elasticsearch.Serverless.Aggregations.SamplerAggregation samplerAggregation) => Set(samplerAggregation, "sampler");
	public AggregationDescriptor<TDocument> Sampler(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SamplerAggregationDescriptor> configure) => Set(configure, "sampler");
	public AggregationDescriptor<TDocument> ScriptedMetric(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ScriptedMetricAggregation scriptedMetricAggregation) => Set(scriptedMetricAggregation, "scripted_metric");
	public AggregationDescriptor<TDocument> ScriptedMetric(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ScriptedMetricAggregationDescriptor<TDocument>> configure) => Set(configure, "scripted_metric");
	public AggregationDescriptor<TDocument> SerialDiff(Elastic.Clients.Elasticsearch.Serverless.Aggregations.SerialDifferencingAggregation serialDifferencingAggregation) => Set(serialDifferencingAggregation, "serial_diff");
	public AggregationDescriptor<TDocument> SerialDiff(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SerialDifferencingAggregationDescriptor> configure) => Set(configure, "serial_diff");
	public AggregationDescriptor<TDocument> SignificantTerms(Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantTermsAggregation significantTermsAggregation) => Set(significantTermsAggregation, "significant_terms");
	public AggregationDescriptor<TDocument> SignificantTerms(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantTermsAggregationDescriptor<TDocument>> configure) => Set(configure, "significant_terms");
	public AggregationDescriptor<TDocument> SignificantText(Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantTextAggregation significantTextAggregation) => Set(significantTextAggregation, "significant_text");
	public AggregationDescriptor<TDocument> SignificantText(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantTextAggregationDescriptor<TDocument>> configure) => Set(configure, "significant_text");
	public AggregationDescriptor<TDocument> Stats(Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsAggregation statsAggregation) => Set(statsAggregation, "stats");
	public AggregationDescriptor<TDocument> Stats(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsAggregationDescriptor<TDocument>> configure) => Set(configure, "stats");
	public AggregationDescriptor<TDocument> StatsBucket(Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsBucketAggregation statsBucketAggregation) => Set(statsBucketAggregation, "stats_bucket");
	public AggregationDescriptor<TDocument> StatsBucket(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsBucketAggregationDescriptor> configure) => Set(configure, "stats_bucket");
	public AggregationDescriptor<TDocument> StringStats(Elastic.Clients.Elasticsearch.Serverless.Aggregations.StringStatsAggregation stringStatsAggregation) => Set(stringStatsAggregation, "string_stats");
	public AggregationDescriptor<TDocument> StringStats(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.StringStatsAggregationDescriptor<TDocument>> configure) => Set(configure, "string_stats");
	public AggregationDescriptor<TDocument> Sum(Elastic.Clients.Elasticsearch.Serverless.Aggregations.SumAggregation sumAggregation) => Set(sumAggregation, "sum");
	public AggregationDescriptor<TDocument> Sum(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SumAggregationDescriptor<TDocument>> configure) => Set(configure, "sum");
	public AggregationDescriptor<TDocument> SumBucket(Elastic.Clients.Elasticsearch.Serverless.Aggregations.SumBucketAggregation sumBucketAggregation) => Set(sumBucketAggregation, "sum_bucket");
	public AggregationDescriptor<TDocument> SumBucket(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SumBucketAggregationDescriptor> configure) => Set(configure, "sum_bucket");
	public AggregationDescriptor<TDocument> Terms(Elastic.Clients.Elasticsearch.Serverless.Aggregations.TermsAggregation termsAggregation) => Set(termsAggregation, "terms");
	public AggregationDescriptor<TDocument> Terms(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TermsAggregationDescriptor<TDocument>> configure) => Set(configure, "terms");
	public AggregationDescriptor<TDocument> TopHits(Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopHitsAggregation topHitsAggregation) => Set(topHitsAggregation, "top_hits");
	public AggregationDescriptor<TDocument> TopHits(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopHitsAggregationDescriptor<TDocument>> configure) => Set(configure, "top_hits");
	public AggregationDescriptor<TDocument> TopMetrics(Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopMetricsAggregation topMetricsAggregation) => Set(topMetricsAggregation, "top_metrics");
	public AggregationDescriptor<TDocument> TopMetrics(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopMetricsAggregationDescriptor<TDocument>> configure) => Set(configure, "top_metrics");
	public AggregationDescriptor<TDocument> TTest(Elastic.Clients.Elasticsearch.Serverless.Aggregations.TTestAggregation tTestAggregation) => Set(tTestAggregation, "t_test");
	public AggregationDescriptor<TDocument> TTest(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TTestAggregationDescriptor<TDocument>> configure) => Set(configure, "t_test");
	public AggregationDescriptor<TDocument> ValueCount(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ValueCountAggregation valueCountAggregation) => Set(valueCountAggregation, "value_count");
	public AggregationDescriptor<TDocument> ValueCount(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ValueCountAggregationDescriptor<TDocument>> configure) => Set(configure, "value_count");
	public AggregationDescriptor<TDocument> VariableWidthHistogram(Elastic.Clients.Elasticsearch.Serverless.Aggregations.VariableWidthHistogramAggregation variableWidthHistogramAggregation) => Set(variableWidthHistogramAggregation, "variable_width_histogram");
	public AggregationDescriptor<TDocument> VariableWidthHistogram(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.VariableWidthHistogramAggregationDescriptor<TDocument>> configure) => Set(configure, "variable_width_histogram");
	public AggregationDescriptor<TDocument> WeightedAvg(Elastic.Clients.Elasticsearch.Serverless.Aggregations.WeightedAverageAggregation weightedAverageAggregation) => Set(weightedAverageAggregation, "weighted_avg");
	public AggregationDescriptor<TDocument> WeightedAvg(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.WeightedAverageAggregationDescriptor<TDocument>> configure) => Set(configure, "weighted_avg");

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (AggregationsValue is not null)
		{
			writer.WritePropertyName("aggregations");
			JsonSerializer.Serialize(writer, AggregationsValue, options);
		}

		if (MetaValue is not null)
		{
			writer.WritePropertyName("meta");
			JsonSerializer.Serialize(writer, MetaValue, options);
		}

		if (!string.IsNullOrEmpty(ContainedVariantName))
		{
			writer.WritePropertyName(ContainedVariantName);
			if (Variant is not null)
			{
				JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options);
				writer.WriteEndObject();
				return;
			}

			JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options);
		}

		writer.WriteEndObject();
	}
}

public sealed partial class AggregationDescriptor : SerializableDescriptor<AggregationDescriptor>
{
	internal AggregationDescriptor(Action<AggregationDescriptor> configure) => configure.Invoke(this);

	public AggregationDescriptor() : base()
	{
	}

	private bool ContainsVariant { get; set; }
	private string ContainedVariantName { get; set; }
	private object Variant { get; set; }
	private Descriptor Descriptor { get; set; }

	private AggregationDescriptor Set<T>(Action<T> descriptorAction, string variantName) where T : Descriptor
	{
		ContainedVariantName = variantName;
		ContainsVariant = true;
		var descriptor = (T)Activator.CreateInstance(typeof(T), true);
		descriptorAction?.Invoke(descriptor);
		Descriptor = descriptor;
		return Self;
	}

	private AggregationDescriptor Set(object variant, string variantName)
	{
		Variant = variant;
		ContainedVariantName = variantName;
		ContainsVariant = true;
		return Self;
	}

	private IDictionary<string, Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregationDescriptor> AggregationsValue { get; set; }
	private IDictionary<string, object>? MetaValue { get; set; }

	/// <summary>
	/// <para>Sub-aggregations for this aggregation.<br/>Only applies to bucket aggregations.</para>
	/// </summary>
	public AggregationDescriptor Aggregations(Func<FluentDescriptorDictionary<string, Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregationDescriptor>, FluentDescriptorDictionary<string, Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregationDescriptor>> selector)
	{
		AggregationsValue = selector?.Invoke(new FluentDescriptorDictionary<string, Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregationDescriptor>());
		return Self;
	}

	public AggregationDescriptor Meta(Func<FluentDictionary<string, object>, FluentDictionary<string, object>> selector)
	{
		MetaValue = selector?.Invoke(new FluentDictionary<string, object>());
		return Self;
	}

	public AggregationDescriptor AdjacencyMatrix(Elastic.Clients.Elasticsearch.Serverless.Aggregations.AdjacencyMatrixAggregation adjacencyMatrixAggregation) => Set(adjacencyMatrixAggregation, "adjacency_matrix");
	public AggregationDescriptor AdjacencyMatrix<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.AdjacencyMatrixAggregationDescriptor> configure) => Set(configure, "adjacency_matrix");
	public AggregationDescriptor AutoDateHistogram(Elastic.Clients.Elasticsearch.Serverless.Aggregations.AutoDateHistogramAggregation autoDateHistogramAggregation) => Set(autoDateHistogramAggregation, "auto_date_histogram");
	public AggregationDescriptor AutoDateHistogram<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.AutoDateHistogramAggregationDescriptor> configure) => Set(configure, "auto_date_histogram");
	public AggregationDescriptor Avg(Elastic.Clients.Elasticsearch.Serverless.Aggregations.AverageAggregation averageAggregation) => Set(averageAggregation, "avg");
	public AggregationDescriptor Avg<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.AverageAggregationDescriptor> configure) => Set(configure, "avg");
	public AggregationDescriptor AvgBucket(Elastic.Clients.Elasticsearch.Serverless.Aggregations.AverageBucketAggregation averageBucketAggregation) => Set(averageBucketAggregation, "avg_bucket");
	public AggregationDescriptor AvgBucket(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.AverageBucketAggregationDescriptor> configure) => Set(configure, "avg_bucket");
	public AggregationDescriptor Boxplot(Elastic.Clients.Elasticsearch.Serverless.Aggregations.BoxplotAggregation boxplotAggregation) => Set(boxplotAggregation, "boxplot");
	public AggregationDescriptor Boxplot<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.BoxplotAggregationDescriptor> configure) => Set(configure, "boxplot");
	public AggregationDescriptor BucketScript(Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketScriptAggregation bucketScriptAggregation) => Set(bucketScriptAggregation, "bucket_script");
	public AggregationDescriptor BucketScript(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketScriptAggregationDescriptor> configure) => Set(configure, "bucket_script");
	public AggregationDescriptor BucketSelector(Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketSelectorAggregation bucketSelectorAggregation) => Set(bucketSelectorAggregation, "bucket_selector");
	public AggregationDescriptor BucketSelector(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketSelectorAggregationDescriptor> configure) => Set(configure, "bucket_selector");
	public AggregationDescriptor BucketSort(Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketSortAggregation bucketSortAggregation) => Set(bucketSortAggregation, "bucket_sort");
	public AggregationDescriptor BucketSort<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketSortAggregationDescriptor> configure) => Set(configure, "bucket_sort");
	public AggregationDescriptor Cardinality(Elastic.Clients.Elasticsearch.Serverless.Aggregations.CardinalityAggregation cardinalityAggregation) => Set(cardinalityAggregation, "cardinality");
	public AggregationDescriptor Cardinality<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.CardinalityAggregationDescriptor> configure) => Set(configure, "cardinality");
	public AggregationDescriptor Children(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ChildrenAggregation childrenAggregation) => Set(childrenAggregation, "children");
	public AggregationDescriptor Children(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ChildrenAggregationDescriptor> configure) => Set(configure, "children");
	public AggregationDescriptor Composite(Elastic.Clients.Elasticsearch.Serverless.Aggregations.CompositeAggregation compositeAggregation) => Set(compositeAggregation, "composite");
	public AggregationDescriptor Composite<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.CompositeAggregationDescriptor> configure) => Set(configure, "composite");
	public AggregationDescriptor CumulativeCardinality(Elastic.Clients.Elasticsearch.Serverless.Aggregations.CumulativeCardinalityAggregation cumulativeCardinalityAggregation) => Set(cumulativeCardinalityAggregation, "cumulative_cardinality");
	public AggregationDescriptor CumulativeCardinality(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.CumulativeCardinalityAggregationDescriptor> configure) => Set(configure, "cumulative_cardinality");
	public AggregationDescriptor CumulativeSum(Elastic.Clients.Elasticsearch.Serverless.Aggregations.CumulativeSumAggregation cumulativeSumAggregation) => Set(cumulativeSumAggregation, "cumulative_sum");
	public AggregationDescriptor CumulativeSum(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.CumulativeSumAggregationDescriptor> configure) => Set(configure, "cumulative_sum");
	public AggregationDescriptor DateHistogram(Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateHistogramAggregation dateHistogramAggregation) => Set(dateHistogramAggregation, "date_histogram");
	public AggregationDescriptor DateHistogram<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateHistogramAggregationDescriptor> configure) => Set(configure, "date_histogram");
	public AggregationDescriptor DateRange(Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateRangeAggregation dateRangeAggregation) => Set(dateRangeAggregation, "date_range");
	public AggregationDescriptor DateRange<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateRangeAggregationDescriptor> configure) => Set(configure, "date_range");
	public AggregationDescriptor Derivative(Elastic.Clients.Elasticsearch.Serverless.Aggregations.DerivativeAggregation derivativeAggregation) => Set(derivativeAggregation, "derivative");
	public AggregationDescriptor Derivative(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.DerivativeAggregationDescriptor> configure) => Set(configure, "derivative");
	public AggregationDescriptor DiversifiedSampler(Elastic.Clients.Elasticsearch.Serverless.Aggregations.DiversifiedSamplerAggregation diversifiedSamplerAggregation) => Set(diversifiedSamplerAggregation, "diversified_sampler");
	public AggregationDescriptor DiversifiedSampler<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.DiversifiedSamplerAggregationDescriptor> configure) => Set(configure, "diversified_sampler");
	public AggregationDescriptor ExtendedStats(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsAggregation extendedStatsAggregation) => Set(extendedStatsAggregation, "extended_stats");
	public AggregationDescriptor ExtendedStats<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsAggregationDescriptor> configure) => Set(configure, "extended_stats");
	public AggregationDescriptor ExtendedStatsBucket(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsBucketAggregation extendedStatsBucketAggregation) => Set(extendedStatsBucketAggregation, "extended_stats_bucket");
	public AggregationDescriptor ExtendedStatsBucket(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsBucketAggregationDescriptor> configure) => Set(configure, "extended_stats_bucket");
	public AggregationDescriptor Filter(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query queryContainer) => Set(queryContainer, "filter");
	public AggregationDescriptor Filter<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.QueryDsl.QueryDescriptor> configure) => Set(configure, "filter");
	public AggregationDescriptor Filters(Elastic.Clients.Elasticsearch.Serverless.Aggregations.FiltersAggregation filtersAggregation) => Set(filtersAggregation, "filters");
	public AggregationDescriptor Filters<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.FiltersAggregationDescriptor> configure) => Set(configure, "filters");
	public AggregationDescriptor FrequentItemSets(Elastic.Clients.Elasticsearch.Serverless.Aggregations.FrequentItemSetsAggregation frequentItemSetsAggregation) => Set(frequentItemSetsAggregation, "frequent_item_sets");
	public AggregationDescriptor FrequentItemSets<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.FrequentItemSetsAggregationDescriptor> configure) => Set(configure, "frequent_item_sets");
	public AggregationDescriptor GeoBounds(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoBoundsAggregation geoBoundsAggregation) => Set(geoBoundsAggregation, "geo_bounds");
	public AggregationDescriptor GeoBounds<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoBoundsAggregationDescriptor> configure) => Set(configure, "geo_bounds");
	public AggregationDescriptor GeoCentroid(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoCentroidAggregation geoCentroidAggregation) => Set(geoCentroidAggregation, "geo_centroid");
	public AggregationDescriptor GeoCentroid<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoCentroidAggregationDescriptor> configure) => Set(configure, "geo_centroid");
	public AggregationDescriptor GeoDistance(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoDistanceAggregation geoDistanceAggregation) => Set(geoDistanceAggregation, "geo_distance");
	public AggregationDescriptor GeoDistance<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoDistanceAggregationDescriptor> configure) => Set(configure, "geo_distance");
	public AggregationDescriptor GeohashGrid(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohashGridAggregation geohashGridAggregation) => Set(geohashGridAggregation, "geohash_grid");
	public AggregationDescriptor GeohashGrid<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohashGridAggregationDescriptor> configure) => Set(configure, "geohash_grid");
	public AggregationDescriptor GeohexGrid(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohexGridAggregation geohexGridAggregation) => Set(geohexGridAggregation, "geohex_grid");
	public AggregationDescriptor GeohexGrid<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohexGridAggregationDescriptor> configure) => Set(configure, "geohex_grid");
	public AggregationDescriptor GeoLine(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoLineAggregation geoLineAggregation) => Set(geoLineAggregation, "geo_line");
	public AggregationDescriptor GeoLine<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoLineAggregationDescriptor> configure) => Set(configure, "geo_line");
	public AggregationDescriptor GeotileGrid(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeotileGridAggregation geotileGridAggregation) => Set(geotileGridAggregation, "geotile_grid");
	public AggregationDescriptor GeotileGrid<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeotileGridAggregationDescriptor> configure) => Set(configure, "geotile_grid");
	public AggregationDescriptor Global(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GlobalAggregation globalAggregation) => Set(globalAggregation, "global");
	public AggregationDescriptor Global(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GlobalAggregationDescriptor> configure) => Set(configure, "global");
	public AggregationDescriptor Histogram(Elastic.Clients.Elasticsearch.Serverless.Aggregations.HistogramAggregation histogramAggregation) => Set(histogramAggregation, "histogram");
	public AggregationDescriptor Histogram<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.HistogramAggregationDescriptor> configure) => Set(configure, "histogram");
	public AggregationDescriptor Inference(Elastic.Clients.Elasticsearch.Serverless.Aggregations.InferenceAggregation inferenceAggregation) => Set(inferenceAggregation, "inference");
	public AggregationDescriptor Inference<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.InferenceAggregationDescriptor> configure) => Set(configure, "inference");
	public AggregationDescriptor IpPrefix(Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpPrefixAggregation ipPrefixAggregation) => Set(ipPrefixAggregation, "ip_prefix");
	public AggregationDescriptor IpPrefix<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpPrefixAggregationDescriptor> configure) => Set(configure, "ip_prefix");
	public AggregationDescriptor IpRange(Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpRangeAggregation ipRangeAggregation) => Set(ipRangeAggregation, "ip_range");
	public AggregationDescriptor IpRange<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpRangeAggregationDescriptor> configure) => Set(configure, "ip_range");
	public AggregationDescriptor Line(Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoLineAggregation geoLineAggregation) => Set(geoLineAggregation, "line");
	public AggregationDescriptor Line<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoLineAggregationDescriptor> configure) => Set(configure, "line");
	public AggregationDescriptor MatrixStats(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MatrixStatsAggregation matrixStatsAggregation) => Set(matrixStatsAggregation, "matrix_stats");
	public AggregationDescriptor MatrixStats<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MatrixStatsAggregationDescriptor> configure) => Set(configure, "matrix_stats");
	public AggregationDescriptor Max(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MaxAggregation maxAggregation) => Set(maxAggregation, "max");
	public AggregationDescriptor Max<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MaxAggregationDescriptor> configure) => Set(configure, "max");
	public AggregationDescriptor MaxBucket(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MaxBucketAggregation maxBucketAggregation) => Set(maxBucketAggregation, "max_bucket");
	public AggregationDescriptor MaxBucket(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MaxBucketAggregationDescriptor> configure) => Set(configure, "max_bucket");
	public AggregationDescriptor MedianAbsoluteDeviation(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MedianAbsoluteDeviationAggregation medianAbsoluteDeviationAggregation) => Set(medianAbsoluteDeviationAggregation, "median_absolute_deviation");
	public AggregationDescriptor MedianAbsoluteDeviation<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MedianAbsoluteDeviationAggregationDescriptor> configure) => Set(configure, "median_absolute_deviation");
	public AggregationDescriptor Min(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MinAggregation minAggregation) => Set(minAggregation, "min");
	public AggregationDescriptor Min<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MinAggregationDescriptor> configure) => Set(configure, "min");
	public AggregationDescriptor MinBucket(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MinBucketAggregation minBucketAggregation) => Set(minBucketAggregation, "min_bucket");
	public AggregationDescriptor MinBucket(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MinBucketAggregationDescriptor> configure) => Set(configure, "min_bucket");
	public AggregationDescriptor Missing(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MissingAggregation missingAggregation) => Set(missingAggregation, "missing");
	public AggregationDescriptor Missing<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MissingAggregationDescriptor> configure) => Set(configure, "missing");
	public AggregationDescriptor MovingFn(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MovingFunctionAggregation movingFunctionAggregation) => Set(movingFunctionAggregation, "moving_fn");
	public AggregationDescriptor MovingFn(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MovingFunctionAggregationDescriptor> configure) => Set(configure, "moving_fn");
	public AggregationDescriptor MovingPercentiles(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MovingPercentilesAggregation movingPercentilesAggregation) => Set(movingPercentilesAggregation, "moving_percentiles");
	public AggregationDescriptor MovingPercentiles(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MovingPercentilesAggregationDescriptor> configure) => Set(configure, "moving_percentiles");
	public AggregationDescriptor MultiTerms(Elastic.Clients.Elasticsearch.Serverless.Aggregations.MultiTermsAggregation multiTermsAggregation) => Set(multiTermsAggregation, "multi_terms");
	public AggregationDescriptor MultiTerms<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.MultiTermsAggregationDescriptor> configure) => Set(configure, "multi_terms");
	public AggregationDescriptor Nested(Elastic.Clients.Elasticsearch.Serverless.Aggregations.NestedAggregation nestedAggregation) => Set(nestedAggregation, "nested");
	public AggregationDescriptor Nested<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.NestedAggregationDescriptor> configure) => Set(configure, "nested");
	public AggregationDescriptor Normalize(Elastic.Clients.Elasticsearch.Serverless.Aggregations.NormalizeAggregation normalizeAggregation) => Set(normalizeAggregation, "normalize");
	public AggregationDescriptor Normalize(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.NormalizeAggregationDescriptor> configure) => Set(configure, "normalize");
	public AggregationDescriptor Parent(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ParentAggregation parentAggregation) => Set(parentAggregation, "parent");
	public AggregationDescriptor Parent(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ParentAggregationDescriptor> configure) => Set(configure, "parent");
	public AggregationDescriptor PercentileRanks(Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentileRanksAggregation percentileRanksAggregation) => Set(percentileRanksAggregation, "percentile_ranks");
	public AggregationDescriptor PercentileRanks<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentileRanksAggregationDescriptor> configure) => Set(configure, "percentile_ranks");
	public AggregationDescriptor Percentiles(Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentilesAggregation percentilesAggregation) => Set(percentilesAggregation, "percentiles");
	public AggregationDescriptor Percentiles<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentilesAggregationDescriptor> configure) => Set(configure, "percentiles");
	public AggregationDescriptor PercentilesBucket(Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentilesBucketAggregation percentilesBucketAggregation) => Set(percentilesBucketAggregation, "percentiles_bucket");
	public AggregationDescriptor PercentilesBucket(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentilesBucketAggregationDescriptor> configure) => Set(configure, "percentiles_bucket");
	public AggregationDescriptor Range(Elastic.Clients.Elasticsearch.Serverless.Aggregations.RangeAggregation rangeAggregation) => Set(rangeAggregation, "range");
	public AggregationDescriptor Range<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.RangeAggregationDescriptor> configure) => Set(configure, "range");
	public AggregationDescriptor RareTerms(Elastic.Clients.Elasticsearch.Serverless.Aggregations.RareTermsAggregation rareTermsAggregation) => Set(rareTermsAggregation, "rare_terms");
	public AggregationDescriptor RareTerms<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.RareTermsAggregationDescriptor> configure) => Set(configure, "rare_terms");
	public AggregationDescriptor Rate(Elastic.Clients.Elasticsearch.Serverless.Aggregations.RateAggregation rateAggregation) => Set(rateAggregation, "rate");
	public AggregationDescriptor Rate<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.RateAggregationDescriptor> configure) => Set(configure, "rate");
	public AggregationDescriptor ReverseNested(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ReverseNestedAggregation reverseNestedAggregation) => Set(reverseNestedAggregation, "reverse_nested");
	public AggregationDescriptor ReverseNested<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ReverseNestedAggregationDescriptor> configure) => Set(configure, "reverse_nested");
	public AggregationDescriptor Sampler(Elastic.Clients.Elasticsearch.Serverless.Aggregations.SamplerAggregation samplerAggregation) => Set(samplerAggregation, "sampler");
	public AggregationDescriptor Sampler(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SamplerAggregationDescriptor> configure) => Set(configure, "sampler");
	public AggregationDescriptor ScriptedMetric(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ScriptedMetricAggregation scriptedMetricAggregation) => Set(scriptedMetricAggregation, "scripted_metric");
	public AggregationDescriptor ScriptedMetric<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ScriptedMetricAggregationDescriptor> configure) => Set(configure, "scripted_metric");
	public AggregationDescriptor SerialDiff(Elastic.Clients.Elasticsearch.Serverless.Aggregations.SerialDifferencingAggregation serialDifferencingAggregation) => Set(serialDifferencingAggregation, "serial_diff");
	public AggregationDescriptor SerialDiff(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SerialDifferencingAggregationDescriptor> configure) => Set(configure, "serial_diff");
	public AggregationDescriptor SignificantTerms(Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantTermsAggregation significantTermsAggregation) => Set(significantTermsAggregation, "significant_terms");
	public AggregationDescriptor SignificantTerms<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantTermsAggregationDescriptor> configure) => Set(configure, "significant_terms");
	public AggregationDescriptor SignificantText(Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantTextAggregation significantTextAggregation) => Set(significantTextAggregation, "significant_text");
	public AggregationDescriptor SignificantText<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantTextAggregationDescriptor> configure) => Set(configure, "significant_text");
	public AggregationDescriptor Stats(Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsAggregation statsAggregation) => Set(statsAggregation, "stats");
	public AggregationDescriptor Stats<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsAggregationDescriptor> configure) => Set(configure, "stats");
	public AggregationDescriptor StatsBucket(Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsBucketAggregation statsBucketAggregation) => Set(statsBucketAggregation, "stats_bucket");
	public AggregationDescriptor StatsBucket(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsBucketAggregationDescriptor> configure) => Set(configure, "stats_bucket");
	public AggregationDescriptor StringStats(Elastic.Clients.Elasticsearch.Serverless.Aggregations.StringStatsAggregation stringStatsAggregation) => Set(stringStatsAggregation, "string_stats");
	public AggregationDescriptor StringStats<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.StringStatsAggregationDescriptor> configure) => Set(configure, "string_stats");
	public AggregationDescriptor Sum(Elastic.Clients.Elasticsearch.Serverless.Aggregations.SumAggregation sumAggregation) => Set(sumAggregation, "sum");
	public AggregationDescriptor Sum<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SumAggregationDescriptor> configure) => Set(configure, "sum");
	public AggregationDescriptor SumBucket(Elastic.Clients.Elasticsearch.Serverless.Aggregations.SumBucketAggregation sumBucketAggregation) => Set(sumBucketAggregation, "sum_bucket");
	public AggregationDescriptor SumBucket(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.SumBucketAggregationDescriptor> configure) => Set(configure, "sum_bucket");
	public AggregationDescriptor Terms(Elastic.Clients.Elasticsearch.Serverless.Aggregations.TermsAggregation termsAggregation) => Set(termsAggregation, "terms");
	public AggregationDescriptor Terms<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TermsAggregationDescriptor> configure) => Set(configure, "terms");
	public AggregationDescriptor TopHits(Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopHitsAggregation topHitsAggregation) => Set(topHitsAggregation, "top_hits");
	public AggregationDescriptor TopHits<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopHitsAggregationDescriptor> configure) => Set(configure, "top_hits");
	public AggregationDescriptor TopMetrics(Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopMetricsAggregation topMetricsAggregation) => Set(topMetricsAggregation, "top_metrics");
	public AggregationDescriptor TopMetrics<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopMetricsAggregationDescriptor> configure) => Set(configure, "top_metrics");
	public AggregationDescriptor TTest(Elastic.Clients.Elasticsearch.Serverless.Aggregations.TTestAggregation tTestAggregation) => Set(tTestAggregation, "t_test");
	public AggregationDescriptor TTest<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.TTestAggregationDescriptor> configure) => Set(configure, "t_test");
	public AggregationDescriptor ValueCount(Elastic.Clients.Elasticsearch.Serverless.Aggregations.ValueCountAggregation valueCountAggregation) => Set(valueCountAggregation, "value_count");
	public AggregationDescriptor ValueCount<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.ValueCountAggregationDescriptor> configure) => Set(configure, "value_count");
	public AggregationDescriptor VariableWidthHistogram(Elastic.Clients.Elasticsearch.Serverless.Aggregations.VariableWidthHistogramAggregation variableWidthHistogramAggregation) => Set(variableWidthHistogramAggregation, "variable_width_histogram");
	public AggregationDescriptor VariableWidthHistogram<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.VariableWidthHistogramAggregationDescriptor> configure) => Set(configure, "variable_width_histogram");
	public AggregationDescriptor WeightedAvg(Elastic.Clients.Elasticsearch.Serverless.Aggregations.WeightedAverageAggregation weightedAverageAggregation) => Set(weightedAverageAggregation, "weighted_avg");
	public AggregationDescriptor WeightedAvg<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Aggregations.WeightedAverageAggregationDescriptor> configure) => Set(configure, "weighted_avg");

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (AggregationsValue is not null)
		{
			writer.WritePropertyName("aggregations");
			JsonSerializer.Serialize(writer, AggregationsValue, options);
		}

		if (MetaValue is not null)
		{
			writer.WritePropertyName("meta");
			JsonSerializer.Serialize(writer, MetaValue, options);
		}

		if (!string.IsNullOrEmpty(ContainedVariantName))
		{
			writer.WritePropertyName(ContainedVariantName);
			if (Variant is not null)
			{
				JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options);
				writer.WriteEndObject();
				return;
			}

			JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options);
		}

		writer.WriteEndObject();
	}
}